package com.dudu.dao;

import java.sql.Connection;
import java.util.List;

import net.sf.json.JSONObject;

import com.dudu.model.QueryStatusAccount;

import core.CoreDao;
import core.CoreService;
import core.db.DBConnectionUtil;

public class SubscriberDao {
	/**
	 * 
	 * @param dao
	 * @param sessionId
	 * @return
	 */
	public QueryStatusAccount queryStatusCountBySessionId(CoreDao dao,String sessionId) {

		Connection con = null;
		QueryStatusAccount result = null;
		
		try {
			con = DBConnectionUtil.getDBConnection("emate1");
			StringBuffer sql = new StringBuffer("SELECT count(*) as recordCount  FROM t_subcriber " +
					"WHERE  conferenceID ='"+sessionId+"'");
			
			sql.append(" and state=1");
			
			CoreService.log.info("queryStatusCountBySessionId sql="+sql.toString());
			
			List<JSONObject> list = dao.serviceJsonSql(con, sql.toString(),new Object[] {
				
				null
				
			});

			List<QueryStatusAccount> items = dao.covertToBean(list, QueryStatusAccount.class);
			result = items.get(0);

		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			DBConnectionUtil.close(null, null, con);
		}
		return result;
	}
	
	
}
